package com.ny.shurushuchu;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class Shuchu {
    public static void main(String[] args) {
        // 要写入的文件路径
        String filePath = "员工.txt";

        try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
            // 写入单行内容
            writer.write("莫大可");
            writer.newLine();

            // 写入多行内容
            writer.write("年龄：21");
            writer.newLine();
            writer.write("电话号码：1381438250");
            writer.write("编号：10015");

            // 刷新缓冲区
            writer.flush();

            System.out.println("文件写入成功！");
        } catch (IOException e) {
            System.err.println("写入文件时出错: " + e.getMessage());
        }
    }
}
